﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace SomethingSpacial.Views.Default
{
    public partial class Directions : UserControl
    {
        public Directions()
        {
            InitializeComponent();
        }

        #region [DependencyProperties]

        public static readonly DependencyProperty DisplayTitleProperty = DependencyProperty.Register("Directions", typeof(string), typeof(Directions), new PropertyMetadata(new PropertyChangedCallback(OnDisplayTitleChanged)));

        public string DisplayTitle
        {
            get { return (string)GetValue(DisplayTitleProperty); }
            set { SetValue(DisplayTitleProperty, value); }
        }

        private static void OnDisplayTitleChanged(DependencyObject DpObj, DependencyPropertyChangedEventArgs e)
        {
            Directions ThisElement = DpObj as Directions;

            if (ThisElement != null)
            {
                TextBlock DisplayTitleTarget = (TextBlock)(ThisElement.FindName("DisplayTitleTarget"));
                DisplayTitleTarget.Text = ThisElement.DisplayTitle;
            }
        }

        public static readonly DependencyProperty DirectionsImageProperty = DependencyProperty.Register(" DirectionsImage", typeof(string), typeof(Directions), new PropertyMetadata(new PropertyChangedCallback(OnDirectionsImageChanged)));

        public string DirectionsImage
        {
            get { return (string)GetValue(DirectionsImageProperty); }
            set { SetValue(DirectionsImageProperty, value); }
        }

        private static void OnDirectionsImageChanged(DependencyObject DpObj, DependencyPropertyChangedEventArgs e)
        {
            Directions ThisElement = DpObj as Directions;

            if (ThisElement != null)
            {
                ImageBrush DisplayTitleTarget = (ImageBrush)(ThisElement.FindName("DirImage"));

                BitmapImage TempImage = new BitmapImage();
                TempImage.UriSource = new Uri(ThisElement.DirectionsImage.ToString(), UriKind.RelativeOrAbsolute);
                DisplayTitleTarget.ImageSource = TempImage;
            }
        }

        public static readonly DependencyProperty DescProperty = DependencyProperty.Register("Directions", typeof(string), typeof(Directions), new PropertyMetadata(new PropertyChangedCallback(OnDescChanged)));

        public string Desc
        {
            get { return (string)GetValue(DescProperty); }
            set { SetValue(DescProperty, value); }
        }

        private static void OnDescChanged(DependencyObject DpObj, DependencyPropertyChangedEventArgs e)
        {
            Directions ThisElement = DpObj as Directions;

            if (ThisElement != null)
            {
                TextBlock DisplayTitleTarget = (TextBlock)(ThisElement.FindName("DescriptionText"));
                DisplayTitleTarget.Text = ThisElement.Desc;
            }
        }

        #endregion
    }
}
